package com.stillalive.springioc.service;

import com.stillalive.springioc.model.Student;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    // 此时存在多个Student类型的Bean，需要添加或更换其他注解
//    @Autowired
//    // 这里将@Primary添加到s1上，注入的就是s1 Bean
//    private Student stuedent;

    // 使用@Resource指定注入对象
    @Resource(name="s1")
    private Student student;

    public void doService(){
        System.out.println(student.getName());
        System.out.println("do service");
    }
}
